# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
#例题3-1
str4= '中国'
bstr4 = str4.encode('utf-8')
bstr4
b'\xe4\xb8\xad\xe5\x9b\xbd'
str5 = bstr4.decode()
print(str5)
#例题3-2
str1='省份\t简称\t省会'
str2='河南\t豫\t郑州'
str3='河北\t冀\t石家庄'
print(str1)
print(str2)
print(str3)
print("-----------------")
#例题3-3
s = "Hello,World"
for i in range(0,len(s)):
print(s [i],end="-")
#例题3-4
import os
#返回指定路径下的文件和文件夹的名名字所组成的列表
items = os.listdir("C:\\Users\\liziyi\\PycharmProjects\\pythonProject")
newlist = []
for names in items:
if names.endswith((".txt", ".docx")):
newlist.append(names)
print(newlist)
#例题3-5
word = input('请输入一个单词:')
if word.islower() or word.isupper() or word.istitle():
print("True")
else:
print('False')
答案: