# -*- coding: UTF-8 -*-'''【程序61】题目:打印出杨辉三角形(要求打印出10行如下图) 1.程序分析: '''if __name__ == '__main__': a = [] for i in range(10): a.append([]) for j in range(10): ...【阅读全文】
为什么Python使用过程中会出现各式各样的乱码问题,明明是中文字符却显示成“/xe4/xb8/xad/xe6/x96/x87”的形式?为什么会报错“UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)”?本文就来研究一下这个问题。字符串在Python内部的表示是unicode编码...【阅读全文】
# -*- coding: UTF-8 -*-'''【程序29】 题目:给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字。1. 程序分析:学会分解出每一位数2.程序源代码:'''x = int(input("input a number:\n"))a = x // 10000b = x // 1000c = x // 100 % 10d = x // 10 % 10e = x % 10if a != 0:...【阅读全文】