323人加入学习
(2人评价)
Python零基础入门学习2020最新版(SiKi)

使用Python3.8 于2019/10/20开始录制

价格 免费
该课程属于 Python人工智能 - A计划(永久有效期) 请加入后再学习

import  os

os.getcwd() 获取文件夹路径

os.chdir() 转移到对应文件夹路径

os.makedirs 生产对应路径文件夹

[展开全文]
# 去除空格 strip()去除左右两端空格  lstrip()去除左端空格  rstrip()去除右端空格
# strip()默认删除空格  完整语法:str.strip([chars])    eg: str.strip('0')
aString = "   abcd ef ghijk   "
print(aString.strip() + "|")     #abcd ef ghijk|
print(aString.lstrip() + "|")    #abcd ef ghijk   |
print(aString.rstrip() + "|")    #   abcd ef ghijk|

 

[展开全文]
# 字符串拼接
string = "Can you put them on " + "hold for me,please?"
print("Can you put them on " + "hold for me,please?")
print(string)      #Can you put them on hold for me,please?
print("Spencer: " + string)    #Spencer: Can you put them on hold for me,please?

# 制表符\t 换行符\n
print("a\tb")
print(len("a\tb"))  #3  #制表符算一个字符
print("a\nb")       #a
                    #b

 

[展开全文]
print("Hello Wrold!")
print('Hello Wrold!')

# "" '' 的使用,转义字符\输出;从第一个引号开始到第二个引号结束
print("I'm fine!")
print('I\'m fine!')   #I'm fine!

# title()函数 大写英文句子每个单词的首字母
msg = "Would you want to have a drink?"
msgA = msg.title()
print(msg)        #Would you want to have a drink?
print(msgA)       #Would You Want To Have A Drink?

# upper()函数 大写英文句子所有字母
msgAll_A = msg.upper()
print(msgAll_A)    #WOULD YOU WANT TO HAVE A DRINK?

# lower()函数 小写英文句子所有字母
msgAll_a = msg.lower()
print(msgAll_a)    #would you want to have a drink?

# len()函数 获取字符串长度
length = len(msg)
print(length)      #31    #空格也算字符

 

[展开全文]

cmd打python跳出应用商店是环境变量有问题

[展开全文]

列表:
    名字 = [数据1, 数据2, ....]

访问列表元素:
    列表名[下标] -- 从零开始, 且索引不存在的数据无法访问

新发现
names = ["111", "222", "333", "444"] #这样写没问题
 names = ["111", "222", "333", "444"] #顶部空一格报错

错误信息:
    IndentationError: unexpected indent

[展开全文]

1. 字符串操作
    str.lstrip() -- 去除头部空白
    str.rstrip() -- 去除尾部空白
    str.strip()  -- 掐头去尾去空白

2. 数字类型
    1. 操作: +, -, *, /, //, %, ** 次方
        % : 取余数(取模)
        // : 舍弃小数部分
        ** : 次方
    2. 转字符串 str()
    3. 转整数 int() -->字符串和小数都可以用
    4. 转浮点数 float()
    5. python 中,字符串和数字不可以直接连接
    
3. 用户输入
    input() --> 字符串

[展开全文]

列表:name = ["aaa","aa","bb","dd"]

截取列表: na = name[0:2]

[展开全文]