1, plastic (int)
py2
int
32-bit PCs: ~ -2147483648 2147483647
Computer 64: 9223372036854775807 ~ -9223372036854775808 beyond the scope of the python automatically converted into a long (long int)
After exceeding the scope of Hu automatically converted into long (long)
Plastic division can retain bit integer, decimal places can not be displayed.
If you want to display all the results in py2 the integer division, joined at the beginning:
from_future_import divsion
py3
int
Integer division retains all
2. Boolean value (bool)
Only two values: True and False
Conversion:
Digital-to-Boolean value: "0" is False, the other is True
String turn Boolean value: "" is False, the other is True
3. The string (str / string)
Sensitive transformation:
value = "doraemon"
new_value = value.upper()
print(new_value)
Enter the code (case insensitive):
check_code = "ifsR"
message = "请出入验证码 %s:" %(check_code,)
code = input(message)
new_check_code = check_code.lower()
new_code = code.lower()
if new_check_code == new_code:
print("输入成功")
******************* **************** isdigit #
Print ( '' 'please call 10086
1. calls inquiry
2 The service handle
3. broadband payment
'' ')
NUM = iNPUT (' please access numbers: ')
In Flag = num.isdigit ()
IF In Flag:
NUM = int (NUM)
Print (NUM)
the else:
Print ( "enter a number : ')
# ********************* remove blank Strip / lstrip / rstrip ********************
the User = input ( "Please enter your user name:")
user1 = user.lstrip ()
user2 = user1.rstrip ()
Print ( "------>", user2, "<------- - ")
# ********************* replace ********************
the Message = the INPUT ( "Please enter content: ")
the Data = message.replace (" your uncle, "" **** ", 1) 1 replaces only the first" your uncle "before 2 is replaced by two
print (data)
#*********************切割split/rsplit********************
message = "我去年买了个表,价值500000,被我拿去送人了"
data = message.split(",")
print(data)
#需求:让用户输入任意字符,获取字符串后并计算有多少个数字
total = 0
text = input("请出入内容:")
len_text = len(text)
index = 0
while True:
val = text[index]
print(val)
if val.isdigit():
total = total + 1
if index == len_text - 1:
break
index += 1
print(total)