1. 安装环境
1.1 官网下载
地址: https://www.python.org/downloads/release/python-382/
下载后直接安装,无脑next
1.2 下载编辑器Pycharm
链接: https://pan.baidu.com/s/1oo8BD4IMQhNmwDYzTeWspQ 提取码: fmtm
破解方法:
- 将下载好的补丁放在idea的安装目录下面的bin文件夹下面
-
修改配置文件
找到bin目录下的pycharm.exe.vmoptions和pycharm64.exe.vmoptions,用记事本打开,在最后一行添加
-javaagent:D:\Software\PyCharm2018.3.4\bin\JetbrainsIdesCrack-4.2-release.jar
-
修改系统的hosts文件
Windows系统hosts文件路径为:c:\windows\system32\drivers\etc
将0.0.0.0 account.jetbrains.com添加到hosts文件最后
-
启动Pycharm破解成功
2. 简单的使用
2.1 字符串API
print('Hello World')
course='Python for Beginners'
#字符串长度
len()
# 字符串转大写
course.upper()
# 字符串转小写
course.lower()
# 字符串首字母大写
course.title()
# 查找字符串返回索引,没有返回-1
course.find()
#字符串替换
course.replace()
#course中是否包含'...',返回布尔类型
'...' in course
2.2 比较运算
name = "zhangsan"
if len(name) < 3:
print("名字不能小于3个字符")
elif len(name) > 50:
print("名字不能大于50个字符")
else:
print("Name looks good")
2.3 将输入数字转为榜还是公斤
weight = int(input('Weight: '))
unit = input('(L)bs or (K)g: ')
if unit.upper() == "L":
converted = weight * 0.45
# 以 f开头表示在字符串内支持大括号内的python 表达式
print(f"You are {converted} kilos")
else:
converted = weight / 0.45
print(f"You are {converted} pounds")
2.4 while循环打印三角形
i = 1
while i<=5:
print('*'*i)
i = i + 1
print('Done')
2.5 猜数字
secret_number = 9
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input('Guess: '))
guess_count = guess_count + 1
if guess == secret_number:
print('You won!')
break
else:
print('Sorry,you failed!')
2.6 控制车辆
command = ""
started = False
while True:
command = input("> ").lower()
if command == "start":
if started:
print("Car is already started!")
else:
started = True
print("Car started...")
elif command == "stop":
if not started:
print("Car is already stopped!")
else:
started = False
print("Car stopped...")
elif command == "help":
print('''
start - to start the car
stop - to stop the car
quit - to quit
''')
elif command == "quit":
break
else:
print("Sorry,I don't understand that!")
网友评论