编写变量相关的内容
This commit is contained in:
parent
ee2e967d6c
commit
6201479731
|
@ -0,0 +1,29 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# import only system from os
|
||||||
|
from os import system, name
|
||||||
|
|
||||||
|
# import sleep to show output for some time period
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
# define our clear function
|
||||||
|
def clear():
|
||||||
|
# for windows
|
||||||
|
if name == 'nt':
|
||||||
|
_ = system('cls')
|
||||||
|
|
||||||
|
# for mac and linux(here, os.name is 'posix')
|
||||||
|
else:
|
||||||
|
_ = system('clear')
|
||||||
|
|
||||||
|
# print out some text
|
||||||
|
|
||||||
|
|
||||||
|
print('Hello CWIKIUS\n' * 10)
|
||||||
|
|
||||||
|
# sleep for 2 seconds after printing output
|
||||||
|
sleep(2)
|
||||||
|
|
||||||
|
# now call function we defined above
|
||||||
|
clear()
|
|
@ -24,9 +24,11 @@ print(x)
|
||||||
print(y)
|
print(y)
|
||||||
|
|
||||||
# 类型转换
|
# 类型转换
|
||||||
x = str(3) # x will be '3'
|
x1 = str(3) # x will be '3'
|
||||||
y = int(3) # y will be 3
|
x2 = int(3) # y will be 3
|
||||||
z = float(3) # z will be 3.0
|
x3 = float(3) # z will be 3.0
|
||||||
|
x4 = chr(31243) # z will be 3.0
|
||||||
|
x5 = ord('程') # z will be 3.0
|
||||||
|
|
||||||
# 获得类型
|
# 获得类型
|
||||||
print("==================")
|
print("==================")
|
||||||
|
|
Loading…
Reference in New Issue