I am creating a simple function to check the special character in Python. We make a Python Program to check if a string contains any special character.
import re
def run(string):
regex = re.compile('[@_!#$%^&*()<>?/|}{~:]')
if(regex.search(string) == None):
print("String value is accepted")
else:
print("String value is not accepted.")
if __name__ == '__main__' :
# Here in "money@rupay" the @ is a special character.
string = "money@rupay"
run(string)
# The Output is:- String value is not accepted.
In function, I check the special characters [@_!#$%^&*()<>?/|}{~:]
reject as String.
It works perfectly.
What is the way to pass special numbers as the restricted number in python?
I want to pass some number as a special number in python like- 9
and 3
. How can I make 9 and 3
as a special number which is restricted in the python program?
question from:
https://stackoverflow.com/questions/65867797/how-can-i-make-two-numbers-9-and-3-as-special-number-in-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…