{"id":37993,"date":"2020-08-29T22:46:31","date_gmt":"2020-08-29T14:46:31","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=37993"},"modified":"2020-08-29T22:47:27","modified_gmt":"2020-08-29T14:47:27","slug":"f455e3b8ec","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=37993","title":{"rendered":"\u5efa\u8bae\u4f60\u5403\u900f Python \u7684 68 \u4e2a\u5185\u7f6e\u51fd\u6570\uff01"},"content":{"rendered":"<div class=\"bpp-post-content\">\n<section>\n<p style=\"text-align: right;\"><span style=\"font-size: 14px;\">\u4f5c\u8005\uff1apypypypy\uff5c \u6765\u6e90\uff1a\u535a\u5ba2\u56ed<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u00a0<\/span><\/p>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u5185\u7f6e\u51fd\u6570\u5c31\u662fPython\u7ed9\u4f60\u63d0\u4f9b\u7684, \u62ff\u6765\u76f4\u63a5\u7528\u7684\u51fd\u6570\uff0c\u6bd4\u5982print\uff0cinput\u7b49\u3002<\/p>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u622a\u6b62\u5230python\u7248\u672c3.6.2 \uff0c\u4e00\u5171\u63d0\u4f9b\u4e8668\u4e2a\u5185\u7f6e\u51fd\u6570\uff0c\u5177\u4f53\u5982\u4e0b\ud83d\udc47<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">abs()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dict()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0help()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0min()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0setattr()<br \/>all()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0dir()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hex()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0next()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0slice()\u00a0<br \/>any()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0divmod()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0id()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0object()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sorted()\u00a0<br \/>ascii()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0enumerate()\u00a0\u00a0\u00a0input()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0oct()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0staticmethod()\u00a0<br \/>bin()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0eval()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0int()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0open()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0str()\u00a0<br \/>bool()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0exec()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0isinstance()\u00a0\u00a0\u00a0ord()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sum()\u00a0<br \/>bytearray()\u00a0\u00a0\u00a0\u00a0\u00a0\ufb01lter()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0issubclass()\u00a0\u00a0\u00a0pow()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0super()\u00a0<br \/>bytes()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\ufb02oat()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0iter()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tuple()\u00a0<br \/>callable()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0format()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0len()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0property()\u00a0\u00a0\u00a0\u00a0type()\u00a0<br \/>chr()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0frozenset()\u00a0\u00a0\u00a0list()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0range()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0vars()\u00a0<br \/>classmethod()\u00a0\u00a0\u00a0getattr()\u00a0\u00a0\u00a0\u00a0\u00a0locals()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0repr()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0zip()\u00a0<br \/>compile()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0globals()\u00a0\u00a0\u00a0\u00a0\u00a0map()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0reversed()\u00a0\u00a0\u00a0\u00a0__import__()\u00a0<br \/>complex()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hasattr()\u00a0\u00a0\u00a0\u00a0\u00a0max()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0round()\u00a0<br \/>delattr()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hash()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0memoryview()\u00a0\u00a0\u00a0set()<br \/><\/code><\/pre>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\"><span style=\"letter-spacing: 0px;\">\u672c\u6587\u5c06\u8fd968\u4e2a\u5185\u7f6e\u51fd\u6570\u7efc\u5408\u6574\u7406\u4e3a12\u5927\u7c7b\uff0c\u6b63\u5728\u5b66\u4e60Python\u57fa\u7840\u7684\u8bfb\u8005\u4e00\u5b9a\u4e0d\u8981\u9519\u8fc7\uff0c\u5efa\u8bae\u6536\u85cf\u5b66\u4e60\uff01<\/span><\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<p>\u548c\u6570\u5b57\u76f8\u5173<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: square;\">\n<li>\n<p>1. \u6570\u636e\u7c7b\u578b<\/p>\n<\/li>\n<li>\n<p>2. \u8fdb\u5236\u8f6c\u6362<\/p>\n<\/li>\n<li>\n<p>3. \u6570\u5b66\u8fd0\u7b97<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u548c\u6570\u636e\u7ed3\u6784\u76f8\u5173<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: square;\">\n<li>\n<p>1. \u5e8f\u5217<\/p>\n<\/li>\n<li>\n<p>2. \u6570\u636e\u96c6\u5408<\/p>\n<\/li>\n<li>\n<p>3. \u76f8\u5173\u5185\u7f6e\u51fd\u6570<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u548c\u4f5c\u7528\u57df\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u548c\u8fed\u4ee3\u5668\u751f\u6210\u5668\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u5b57\u7b26\u4e32\u7c7b\u578b\u4ee3\u7801\u7684\u6267\u884c<\/p>\n<\/li>\n<li>\n<p>\u8f93\u5165\u8f93\u51fa<\/p>\n<\/li>\n<li>\n<p>\u5185\u5b58\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u6587\u4ef6\u64cd\u4f5c\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u6a21\u5757\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u5e2e \u00a0\u52a9<\/p>\n<\/li>\n<li>\n<p>\u8c03\u7528\u76f8\u5173<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u5185\u7f6e\u5c5e\u6027<\/p>\n<\/li>\n<\/ul>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u548c\u6570\u5b57\u76f8\u5173<\/span><\/h2>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">1. \u6570\u636e\u7c7b\u578b<\/span><\/h3>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">bool : \u5e03\u5c14\u578b(True,False)<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">int : \u6574\u578b(\u6574\u6570)<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">float : \u6d6e\u70b9\u578b(\u5c0f\u6570)<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">complex : \u590d\u6570<\/section>\n<\/li>\n<\/ul>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">2. \u8fdb\u5236\u8f6c\u6362<\/span><\/h3>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">bin() \u5c06\u7ed9\u7684\u53c2\u6570\u8f6c\u6362\u6210\u4e8c\u8fdb\u5236<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">otc() \u5c06\u7ed9\u7684\u53c2\u6570\u8f6c\u6362\u6210\u516b\u8fdb\u5236<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">hex() \u5c06\u7ed9\u7684\u53c2\u6570\u8f6c\u6362\u6210\u5341\u516d\u8fdb\u5236<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(bin(10))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u4e8c\u8fdb\u5236:0b1010<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(hex(10))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5341\u516d\u8fdb\u5236:0xa<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(oct(10))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u516b\u8fdb\u5236:0o12<\/span><br \/><\/code><\/pre>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">3. \u6570\u5b66\u8fd0\u7b97<\/span><\/h3>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">abs() \u8fd4\u56de\u7edd\u5bf9\u503c<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">divmode() \u8fd4\u56de\u5546\u548c\u4f59\u6570<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">round() \u56db\u820d\u4e94\u5165<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">pow(a, b) \u6c42a\u7684b\u6b21\u5e42, \u5982\u679c\u6709\u4e09\u4e2a\u53c2\u6570. \u5219\u6c42\u5b8c\u6b21\u5e42\u540e\u5bf9\u7b2c\u4e09\u4e2a\u6570\u53d6\u4f59<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">sum() \u6c42\u548c<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">min() \u6c42\u6700\u5c0f\u503c<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">max() \u6c42\u6700\u5927\u503c<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(abs(-2))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u7edd\u5bf9\u503c:2<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(divmod(20,3))\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u6c42\u5546\u548c\u4f59\u6570:(6,2)<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(round(4.50))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u4e94\u820d\u516d\u5165:4<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(round(4.51))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#5<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(pow(10,2,3))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5982\u679c\u7ed9\u4e86\u7b2c\u4e09\u4e2a\u53c2\u6570.\u00a0\u8868\u793a\u6700\u540e\u53d6\u4f59:1<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(sum([1,2,3,4,5,6,7,8,9,10]))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u6c42\u548c:55<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(min(5,3,9,12,7,2))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u6c42\u6700\u5c0f\u503c:2<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(max(7,3,15,9,4,13))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u6c42\u6700\u5927\u503c:15<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u548c\u6570\u636e\u7ed3\u6784\u76f8\u5173<\/span><\/h2>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">1. \u5e8f\u5217<\/span><\/h3>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\uff081\uff09\u5217\u8868\u548c\u5143\u7ec4<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">list() \u5c06\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8f6c\u6362\u6210\u5217\u8868<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">tuple() \u5c06\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8f6c\u6362\u6210\u5143\u7ec4<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(list((1,2,3,4,5,6)))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[1,\u00a02,\u00a03,\u00a04,\u00a05,\u00a06]<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(tuple([1,2,3,4,5,6]))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#(1,\u00a02,\u00a03,\u00a04,\u00a05,\u00a06)<\/span><br \/><\/code><\/pre>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\uff082\uff09\u76f8\u5173\u5185\u7f6e\u51fd\u6570<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">reversed() \u5c06\u4e00\u4e2a\u5e8f\u5217\u7ffb\u8f6c, \u8fd4\u56de\u7ffb\u8f6c\u5e8f\u5217\u7684\u8fed\u4ee3\u5668<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">slice() \u5217\u8868\u7684\u5207\u7247<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">lst\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\u4f60\u597d\u554a\"<\/span><br \/>it\u00a0=\u00a0reversed(lst)\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u4e0d\u4f1a\u6539\u53d8\u539f\u5217\u8868.\u00a0\u8fd4\u56de\u4e00\u4e2a\u8fed\u4ee3\u5668,\u00a0\u8bbe\u8ba1\u4e0a\u7684\u4e00\u4e2a\u89c4\u5219<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(list(it))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#['\u554a',\u00a0'\u597d',\u00a0'\u4f60']<\/span><br \/>lst\u00a0=\u00a0[1,\u00a02,\u00a03,\u00a04,\u00a05,\u00a06,\u00a07]<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(lst[1:3:1])\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[2,3]<\/span><br \/>s\u00a0=\u00a0slice(1,\u00a03,\u00a01)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u00a0\u5207\u7247\u7528\u7684<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(lst[s])\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[2,3]<\/span><br \/><\/code><\/pre>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\uff083\uff09\u5b57\u7b26\u4e32<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">str() \u5c06\u6570\u636e\u8f6c\u5316\u6210\u5b57\u7b26\u4e32<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(str(123)+<span style=\"color: #98c379; line-height: 26px;\">'456'<\/span>)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#123456<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">format() \u00a0 \u00a0 \u4e0e\u5177\u4f53\u6570\u636e\u76f8\u5173, \u7528\u4e8e\u8ba1\u7b97\u5404\u79cd\u5c0f\u6570, \u7cbe\u7b97\u7b49.<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">s\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"hello\u00a0world!\"<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(s,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"^20\"<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u5267\u4e2d<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(s,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"&lt;20\"<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u5de6\u5bf9\u9f50<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(s,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"&gt;20\"<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u53f3\u5bf9\u9f50<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u00a0\u00a0\u00a0\u00a0hello\u00a0world!\u00a0\u00a0\u00a0\u00a0<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0hello\u00a0world!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hello\u00a0world!<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(3,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'b'<\/span>\u00a0))\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u4e8c\u8fdb\u5236:11<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(97,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'c'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u8f6c\u6362\u6210unicode\u5b57\u7b26:a<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'d'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u2f17\u8fdb\u5236:11<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'o'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u516b\u8fdb\u5236:13\u00a0<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'x'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5341\u516d\u8fdb\u5236(\u2f29\u5199\u5b57\u6bcd):b<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'X'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5341\u516d\u8fdb\u5236(\u5927\u5199\u5b57\u6bcd):B<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'n'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u548cd\u2f00\u6837:11<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(11))\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u548cd\u2f00\u6837:11<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(123456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'e'<\/span>\u00a0))\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u79d1\u5b66\u8ba1\u6570\u6cd5.\u00a0\u9ed8\u8ba4\u4fdd\u75596\u4f4d\u5c0f\u6570:1.234568e+08<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(123456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'0.2e'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u79d1\u5b66\u8ba1\u6570\u6cd5.\u00a0\u4fdd\u75592\u4f4d\u5c0f\u6570(\u5c0f\u5199):1.23e+08<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(123456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'0.2E'<\/span>\u00a0))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u79d1\u5b66\u8ba1\u6570\u6cd5.\u00a0\u4fdd\u75592\u4f4d\u5c0f\u6570(\u5927\u5199):1.23E+08<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(1.23456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'f'<\/span>\u00a0))\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5c0f\u6570\u70b9\u8ba1\u6570\u6cd5.\u00a0\u4fdd\u75596\u4f4d\u5c0f\u6570:1.234568<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(1.23456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'0.2f'<\/span>\u00a0))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5c0f\u6570\u70b9\u8ba1\u6570\u6cd5.\u00a0\u4fdd\u75592\u4f4d\u5c0f\u6570:1.23<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(1.23456789,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'0.10f'<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5c0f\u6570\u70b9\u8ba1\u6570\u6cd5.\u00a0\u4fdd\u755910\u4f4d\u5c0f\u6570:1.2345678900<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(format(1.23456789e+3,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'F'<\/span>))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5c0f\u6570\u70b9\u8ba1\u6570\u6cd5.\u00a0\u5f88\u5927\u7684\u65f6\u5019\u8f93\u51faINF:1234.567890<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">bytes() \u628a\u5b57\u7b26\u4e32\u8f6c\u5316\u6210bytes\u7c7b\u578b<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">bs\u00a0=\u00a0bytes(<span style=\"color: #98c379; line-height: 26px;\">\"\u4eca\u5929\u5403\u996d\u4e86\u5417\"<\/span>,\u00a0encoding=<span style=\"color: #98c379; line-height: 26px;\">\"utf-8\"<\/span>)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(bs)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#b'xe4xbbx8axe5xa4xa9xe5x90x83xe9xa5xadxe4xbax86xe5x90x97'<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">bytearray() \u00a0 \u00a0\u8fd4\u56de\u4e00\u4e2a\u65b0\u5b57\u8282\u6570\u7ec4. \u8fd9\u4e2a\u6570\u5b57\u7684\u5143\u7d20\u662f\u53ef\u53d8\u7684, \u5e76\u4e14\u6bcf\u4e2a\u5143\u7d20\u7684\u503c\u5f97\u8303\u56f4\u662f[0,256)<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">ret\u00a0=\u00a0bytearray(<span style=\"color: #98c379; line-height: 26px;\">\"alex\"<\/span>\u00a0,encoding\u00a0=<span style=\"color: #98c379; line-height: 26px;\">'utf-8'<\/span>)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ret[0])\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#97<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ret)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#bytearray(b'alex')<\/span><br \/>ret[0]\u00a0=\u00a065\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u628a65\u7684\u4f4d\u7f6eA\u8d4b\u503c\u7ed9ret[0]<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(str(ret))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#bytearray(b'Alex')<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">ord() \u8f93\u5165\u5b57\u7b26\u627e\u5e26\u5b57\u7b26\u7f16\u7801\u7684\u4f4d\u7f6e<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">chr() \u8f93\u5165\u4f4d\u7f6e\u6570\u5b57\u627e\u51fa\u5bf9\u5e94\u7684\u5b57\u7b26<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">ascii() \u662fascii\u7801\u4e2d\u7684\u8fd4\u56de\u8be5\u503c \u4e0d\u662f\u5c31\u8fd4\u56deu<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ord(<span style=\"color: #98c379; line-height: 26px;\">'a'<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5b57\u6bcda\u5728\u7f16\u7801\u8868\u4e2d\u7684\u7801\u4f4d:97<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ord(<span style=\"color: #98c379; line-height: 26px;\">'\u4e2d'<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0'\u4e2d'\u5b57\u5728\u7f16\u7801\u8868\u4e2d\u7684\u4f4d\u7f6e:20013<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(chr(65))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5df2\u77e5\u7801\u4f4d,\u6c42\u5b57\u7b26\u662f\u4ec0\u4e48:A<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(chr(19999))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u4e1f<\/span><br \/><br \/><span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0i\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0range(65536):\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u6253\u5370\u51fa0\u523065535\u7684\u5b57\u7b26<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(chr(i),\u00a0end=<span style=\"color: #98c379; line-height: 26px;\">\"\u00a0\"<\/span>)<br \/><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ascii(<span style=\"color: #98c379; line-height: 26px;\">\"@\"<\/span>))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#'@'<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">repr() \u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\u7684string\u5f62\u5f0f<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">s\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\u4eca\u5929n\u5403\u4e86%s\u987ft\u996d\"<\/span>\u00a0%\u00a03<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(s)<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u4eca\u5929#\u00a0\u5403\u4e863\u987f\u00a0\u00a0\u00a0\u00a0\u996d<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(repr(s))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u539f\u6837\u8f93\u51fa,\u8fc7\u6ee4\u6389\u8f6c\u4e49\u5b57\u7b26\u00a0n\u00a0t\u00a0r\u00a0\u4e0d\u7ba1\u767e\u5206\u53f7%<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#'\u4eca\u5929n\u5403\u4e863\u987ft\u996d'<\/span><br \/><\/code><\/pre>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">2. \u6570\u636e\u96c6\u5408<\/span><\/h3>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">\u5b57\u5178\uff1adict \u521b\u5efa\u4e00\u4e2a\u5b57\u5178<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">\u96c6\u5408\uff1aset \u521b\u5efa\u4e00\u4e2a\u96c6\u5408<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">frozenset() \u521b\u5efa\u4e00\u4e2a\u51bb\u7ed3\u7684\u96c6\u5408\uff0c\u51bb\u7ed3\u7684\u96c6\u5408\u4e0d\u80fd\u8fdb\u884c\u6dfb\u52a0\u548c\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<h3 style=\"font-weight: bold; font-size: 20px; line-height: 1.4; padding-top: 10px; margin-top: 10px; margin-bottom: 5px;\"><span style=\"color: #515151; font-size: 1em; padding-left: 20px; border-left: 3px solid #f9bf45;\">3. \u76f8\u5173\u5185\u7f6e\u51fd\u6570<\/span><\/h3>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">len() \u8fd4\u56de\u4e00\u4e2a\u5bf9\u8c61\u4e2d\u7684\u5143\u7d20\u7684\u4e2a\u6570<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">sorted() \u5bf9\u53ef\u8fed\u4ee3\u5bf9\u8c61\u8fdb\u884c\u6392\u5e8f\u64cd\u4f5c (lamda)<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u8bed\u6cd5\uff1asorted(Iterable, key=\u51fd\u6570(\u6392\u5e8f\u89c4\u5219), reverse=False)<\/p>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">Iterable: \u53ef\u8fed\u4ee3\u5bf9\u8c61<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">key: \u6392\u5e8f\u89c4\u5219(\u6392\u5e8f\u51fd\u6570), \u5728sorted\u5185\u90e8\u4f1a\u5c06\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u4f20\u9012\u7ed9\u8fd9\u4e2a\u51fd\u6570\u7684\u53c2\u6570. \u6839\u636e\u51fd\u6570\u8fd0\u7b97\u7684\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">reverse: \u662f\u5426\u662f\u5012\u53d9. True: \u5012\u53d9, False: \u6b63\u5e8f<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">lst\u00a0=\u00a0[5,7,6,12,1,13,9,18,5]<br \/>lst.sort()\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0sort\u662flist\u91cc\u9762\u7684\u4e00\u4e2a\u65b9\u6cd5<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(lst)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[1,\u00a05,\u00a05,\u00a06,\u00a07,\u00a09,\u00a012,\u00a013,\u00a018]<\/span><br \/><br \/>ll\u00a0=\u00a0sorted(lst)\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5185\u7f6e\u51fd\u6570.\u00a0\u8fd4\u56de\u7ed9\u4f60\u4e00\u4e2a\u65b0\u5217\u8868\u00a0\u00a0\u65b0\u5217\u8868\u662f\u88ab\u6392\u5e8f\u7684<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(ll)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[1,\u00a05,\u00a05,\u00a06,\u00a07,\u00a09,\u00a012,\u00a013,\u00a018]<\/span><br \/><br \/>l2\u00a0=\u00a0sorted(lst,reverse=True)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u5012\u5e8f<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(l2)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[18,\u00a013,\u00a012,\u00a09,\u00a07,\u00a06,\u00a05,\u00a05,\u00a01]<\/span><br \/><\/code><\/pre>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u6839\u636e\u5b57\u7b26\u4e32\u957f\u5ea6\u7ed9\u5217\u8868\u6392\u5e8f<\/span><br \/>lst\u00a0=\u00a0[<span style=\"color: #98c379; line-height: 26px;\">'one'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'two'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'three'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'four'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'five'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'six'<\/span>]<br \/>def\u00a0f(s):<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">return<\/span>\u00a0len(s)<br \/>l1\u00a0=\u00a0sorted(lst,\u00a0key=f,\u00a0)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(l1)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#['one',\u00a0'two',\u00a0'six',\u00a0'four',\u00a0'five',\u00a0'three']<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">enumerate() \u83b7\u53d6\u96c6\u5408\u7684\u679a\u4e3e\u5bf9\u8c61<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">lst\u00a0=\u00a0[<span style=\"color: #98c379; line-height: 26px;\">'one'<\/span>,<span style=\"color: #98c379; line-height: 26px;\">'two'<\/span>,<span style=\"color: #98c379; line-height: 26px;\">'three'<\/span>,<span style=\"color: #98c379; line-height: 26px;\">'four'<\/span>,<span style=\"color: #98c379; line-height: 26px;\">'five'<\/span>]<br \/><span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0index,\u00a0el\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0enumerate(lst,1):\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u628a\u7d22\u5f15\u548c\u5143\u7d20\u4e00\u8d77\u83b7\u53d6,\u7d22\u5f15\u9ed8\u8ba4\u4ece0\u5f00\u59cb.\u00a0\u53ef\u4ee5\u66f4\u6539<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(index)<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(el)<br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a01<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0one<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a02<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0two<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a03<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0three<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a04<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0four<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a05<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0five<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">all() \u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u5168\u90e8\u662fTrue, \u7ed3\u679c\u624d\u662fTrue<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">any() \u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u6709\u4e00\u4e2a\u662fTrue, \u7ed3\u679c\u5c31\u662fTrue<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(all([1,<span style=\"color: #98c379; line-height: 26px;\">'hello'<\/span>,True,9]))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#True<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(any([0,0,0,False,1,<span style=\"color: #98c379; line-height: 26px;\">'good'<\/span>]))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#True<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">zip() \u51fd\u6570\u7528\u4e8e\u5c06\u53ef\u8fed\u4ee3\u7684\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570, \u5c06\u5bf9\u8c61\u4e2d\u5bf9\u5e94\u7684\u5143\u7d20\u6253\u5305\u6210\u4e00\u4e2a\u5143\u7ec4, \u7136\u540e\u8fd4\u56de\u7531\u8fd9\u4e9b\u5143\u7ec4\u7ec4\u6210\u7684\u5217\u8868. \u5982\u679c\u5404\u4e2a\u8fed\u4ee3\u5668\u7684\u5143\u7d20\u4e2a\u6570\u4e0d\u4e00\u81f4, \u5219\u8fd4\u56de\u5217\u8868\u957f\u5ea6\u4e0e\u6700\u77ed\u7684\u5bf9\u8c61\u76f8\u540c<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">lst1\u00a0=\u00a0[1,\u00a02,\u00a03,\u00a04,\u00a05,\u00a06]<br \/>lst2\u00a0=\u00a0[<span style=\"color: #98c379; line-height: 26px;\">'\u9189\u4e61\u6c11\u8c23'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u9a74\u5f97\u6c34'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u653e\u725b\u73ed\u7684\u6625\u5929'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u7f8e\u4e3d\u4eba\u751f'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u8fa9\u62a4\u4eba'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u88ab\u5acc\u5f03\u7684\u677e\u5b50\u7684\u4e00\u751f'<\/span>]<br \/>lst3\u00a0=\u00a0[<span style=\"color: #98c379; line-height: 26px;\">'\u7f8e\u56fd'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u4e2d\u56fd'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u6cd5\u56fd'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u610f\u5927\u5229'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u97e9\u56fd'<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">'\u65e5\u672c'<\/span>]<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(zip(lst1,\u00a0lst1,\u00a0lst3))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#&lt;zip\u00a0object\u00a0at\u00a00x00000256CA6C7A88&gt;<\/span><br \/><span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0el\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0zip(lst1,\u00a0lst2,\u00a0lst3):<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(el)<br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(1,\u00a0'\u9189\u4e61\u6c11\u8c23',\u00a0'\u7f8e\u56fd')<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(2,\u00a0'\u9a74\u5f97\u6c34',\u00a0'\u4e2d\u56fd')<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(3,\u00a0'\u653e\u725b\u73ed\u7684\u6625\u5929',\u00a0'\u6cd5\u56fd')<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(4,\u00a0'\u7f8e\u4e3d\u4eba\u751f',\u00a0'\u610f\u5927\u5229')<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(5,\u00a0'\u8fa9\u62a4\u4eba',\u00a0'\u97e9\u56fd')<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(6,\u00a0'\u88ab\u5acc\u5f03\u7684\u677e\u5b50\u7684\u4e00\u751f',\u00a0'\u65e5\u672c')<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">fiter() \u8fc7\u6ee4 (lamda)<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u8bed\u6cd5\uff1afiter(function. Iterable)<\/p>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">function: \u7528\u6765\u7b5b\u9009\u7684\u51fd\u6570. \u5728\ufb01lter\u4e2d\u4f1a\u81ea\u52a8\u7684\u628aiterable\u4e2d\u7684\u5143\u7d20\u4f20\u9012\u7ed9function. \u7136\u540e\u6839\u636efunction\u8fd4\u56de\u7684True\u6216\u8005False\u6765\u5224\u65ad\u662f\u5426\u4fdd\u7559\uf9cd\u6b64\u9879\u6570\u636e , Iterable: \u53ef\u8fed\u4ee3\u5bf9\u8c61<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">def\u00a0func(i):\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5224\u65ad\u5947\u6570<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">return<\/span>\u00a0i\u00a0%\u00a02\u00a0==\u00a01<br \/>\u00a0\u00a0\u00a0\u00a0lst\u00a0=\u00a0[1,2,3,4,5,6,7,8,9]<br \/>l1\u00a0=\u00a0filter(func,\u00a0lst)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#l1\u662f\u8fed\u4ee3\u5668<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(l1)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#&lt;filter\u00a0object\u00a0at\u00a00x000001CE3CA98AC8&gt;<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(list(l1))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#[1,\u00a03,\u00a05,\u00a07,\u00a09]<\/span><br \/><\/code><\/pre>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">map() \u4f1a\u6839\u636e\u63d0\u4f9b\u7684\u51fd\u6570\u5bf9\u6307\u5b9a\u5e8f\u5217\uf99c\u505a\u6620\u5c04(lamda)<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u8bed\u6cd5 : map(function, iterable)<\/p>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">\u53ef\u4ee5\u5bf9\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u8fdb\u884c\u6620\u5c04. \u5206\u522b\u53bb\u6267\u884c function<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">def\u00a0f(i):\u00a0\u00a0\u00a0\u00a0<br \/>\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">return<\/span>\u00a0i<br \/>\u00a0\u00a0lst\u00a0=\u00a0[1,2,3,4,5,6,7,]<br \/>it\u00a0=\u00a0map(f,\u00a0lst)\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u628a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u4f20\u9012\u7ed9\u524d\u9762\u7684\u51fd\u6570\u8fdb\u884c\u5904\u7406.\u00a0\u5904\u7406\u7684\u7ed3\u679c\u4f1a\u8fd4\u56de\u6210\u8fed\u4ee3\u5668print(list(it))\u00a0\u00a0#[1,\u00a02,\u00a03,\u00a04,\u00a05,\u00a06,\u00a07]<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u548c\u4f5c\u7528\u57df\u76f8\u5173<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">locals() \u8fd4\u56de\u5f53\u524d\u4f5c\u7528\u57df\u4e2d\u7684\u540d\u5b57<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">globals() \u8fd4\u56de\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u7684\u540d\u5b57<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">def\u00a0func():<br \/>\u00a0\u00a0\u00a0\u00a0a\u00a0=\u00a010<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(locals())\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5f53\u524d\u4f5c\u7528\u57df\u4e2d\u7684\u5185\u5bb9<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(globals())\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u5168\u5c40\u4f5c\u7528\u57df\u4e2d\u7684\u5185\u5bb9<\/span><br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"\u4eca\u5929\u5185\u5bb9\u5f88\u591a\"<\/span>)<br \/>func()<br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0{'a':\u00a010}<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0{'__name__':\u00a0'__main__',\u00a0'__doc__':\u00a0None,\u00a0'__package__':\u00a0None,\u00a0'__loader__':\u00a0<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0&lt;_frozen_importlib_external.SourceFileLoader\u00a0object\u00a0at\u00a00x0000026F8D566080&gt;,\u00a0<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0'__spec__':\u00a0None,\u00a0'__annotations__':\u00a0{},\u00a0'__builtins__':\u00a0&lt;module\u00a0'builtins'\u00a0<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0(built-in)&gt;,\u00a0'__file__':\u00a0'D:\/pycharm\/\u7ec3\u4e60\/week03\/new14.py',\u00a0'__cached__':\u00a0None,<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u00a0'func':\u00a0&lt;function\u00a0func\u00a0at\u00a00x0000026F8D6B97B8&gt;}<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u4eca\u5929\u5185\u5bb9\u5f88\u591a<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u548c\u8fed\u4ee3\u5668\u751f\u6210\u5668\u76f8\u5173<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">range() \u751f\u6210\u6570\u636e<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">next() \u8fed\u4ee3\u5668\u5411\u4e0b\u6267\u884c\u4e00\u6b21, \u5185\u90e8\u5b9e\u9645\u4f7f\u7528\u4e86__ next__()\u65b9\u6cd5\u8fd4\u56de\u8fed\u4ee3\u5668\u7684\u4e0b\u4e00\u4e2a\u9879\u76ee<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">iter() \u83b7\u53d6\u8fed\u4ee3\u5668, \u5185\u90e8\u5b9e\u9645\u4f7f\u7528\u7684\u662f__ iter__()\u65b9\u6cd5\u6765\u83b7\u53d6\u8fed\u4ee3\u5668<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0i\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0range(15,-1,-5):<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(i)<br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a015<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a010<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a05<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a00<\/span><br \/>lst\u00a0=\u00a0[1,2,3,4,5]<br \/>it\u00a0=\u00a0iter(lst)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u00a0__iter__()\u83b7\u5f97\u8fed\u4ee3\u5668<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(it.__next__())\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#1<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(next(it))\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#2\u00a0\u00a0__next__()\u00a0\u00a0<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(next(it))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#3<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(next(it))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#4<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u5b57\u7b26\u4e32\u7c7b\u578b\u4ee3\u7801\u7684\u6267\u884c<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">eval() \u6267\u884c\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u4ee3\u7801. \u5e76\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">exec() \u6267\u884c\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u4ee3\u7801<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">compile() \u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u4ee3\u7801\u7f16\u7801. \u4ee3\u7801\u5bf9\u8c61\u80fd\u591f\u901a\u8fc7exec\u8bed\u53e5\u6765\u6267\u884c\u6216\u8005eval()\u8fdb\u884c\u6c42\u503c<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">s1\u00a0=\u00a0input(<span style=\"color: #98c379; line-height: 26px;\">\"\u8bf7\u8f93\u5165a+b:\"<\/span>)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u8f93\u5165:8+9<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #e6c07b; line-height: 26px;\">eval<\/span>(s1))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a017\u00a0\u53ef\u4ee5\u52a8\u6001\u7684\u6267\u884c\u4ee3\u7801.\u00a0\u4ee3\u7801\u5fc5\u987b\u6709\u8fd4\u56de\u503c<\/span><br \/>s2\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"for\u00a0i\u00a0in\u00a0range(5):\u00a0print(i)\"<\/span><br \/>a\u00a0=\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">exec<\/span>(s2)\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0exec\u00a0\u6267\u884c\u4ee3\u7801\u4e0d\u8fd4\u56de\u4efb\u4f55\u5185\u5bb9<\/span><br \/><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a00<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a01<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a02<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a03<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a04<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(a)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#None<\/span><br \/><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u52a8\u6001\u6267\u884c\u4ee3\u7801<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">exec<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span><span style=\"color: #98c379; line-height: 26px;\">\"<br \/>def\u00a0func():<br \/>\u00a0\u00a0\u00a0\u00a0print(\"<\/span>\u00a0\u6211\u662f\u5468\u6770\u4f26<span style=\"color: #98c379; line-height: 26px;\">\")<br \/>\"<\/span><span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>\u00a0)<br \/>func()\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u6211\u662f\u5468\u6770\u4f26<\/span><br \/><br \/>code1\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"for\u00a0i\u00a0in\u00a0range(3):\u00a0print(i)\"<\/span><br \/>com\u00a0=\u00a0compile(code1,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>,\u00a0mode=<span style=\"color: #98c379; line-height: 26px;\">\"exec\"<\/span>)\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0compile\u5e76\u4e0d\u4f1a\u6267\u884c\u4f60\u7684\u4ee3\u7801.\u53ea\u662f\u7f16\u8bd1<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">exec<\/span>(com)\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u6267\u884c\u7f16\u8bd1\u7684\u7ed3\u679c<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a00<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a01<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a02<\/span><br \/><br \/>code2\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"5+6+7\"<\/span><br \/>com2\u00a0=\u00a0compile(code2,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>,\u00a0mode=<span style=\"color: #98c379; line-height: 26px;\">\"eval\"<\/span>)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #e6c07b; line-height: 26px;\">eval<\/span>(com2))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a018<\/span><br \/><br \/>code3\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"name\u00a0=\u00a0input('\u8bf7\u8f93\u5165\u4f60\u7684\u540d\u5b57:')\"<\/span>\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u8f93\u5165:hello<\/span><br \/>com3\u00a0=\u00a0compile(code3,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>,\u00a0mode=<span style=\"color: #98c379; line-height: 26px;\">\"single\"<\/span>)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">exec<\/span>(com3)<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(name)\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#hello<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u8f93\u5165\u8f93\u51fa<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">print() : \u6253\u5370\u8f93\u51fa<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">input() : \u83b7\u53d6\u7528\u6237\u8f93\u51fa\u7684\u5185\u5bb9<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"hello\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"world\"<\/span>,\u00a0sep=<span style=\"color: #98c379; line-height: 26px;\">\"*\"<\/span>,\u00a0end=<span style=\"color: #98c379; line-height: 26px;\">\"@\"<\/span>)\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0sep:\u6253\u5370\u51fa\u7684\u5185\u5bb9\u7528\u4ec0\u4e48\u8fde\u63a5,end:\u4ee5\u4ec0\u4e48\u4e3a\u7ed3\u5c3e<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#hello*world@<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u5185\u5b58\u76f8\u5173<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">hash() : \u83b7\u53d6\u5230\u5bf9\u8c61\u7684\u54c8\u5e0c\u503c(int, str, bool, tuple). hash\u7b97\u6cd5:(1) \u76ee\u7684\u662f\u552f\u4e00\u6027 (2) dict \u67e5\u627e\u6548\u7387\u975e\u5e38\u9ad8, hash\u8868.\u7528\u7a7a\u95f4\u6362\u7684\u65f6\u95f4 \u6bd4\u8f83\u8017\u8d39\u5185\u5b58<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><br \/>s\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">'alex'<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #e6c07b; line-height: 26px;\">hash<\/span>(s))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#-168324845050430382<\/span><br \/>lst\u00a0=\u00a0[1,\u00a02,\u00a03,\u00a04,\u00a05]<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #e6c07b; line-height: 26px;\">hash<\/span>(lst))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u62a5\u9519,\u5217\u8868\u662f\u4e0d\u53ef\u54c8\u5e0c\u7684<\/span><br \/>\u00a0\u00a0id()\u00a0:\u00a0\u00a0\u83b7\u53d6\u5230\u5bf9\u8c61\u7684\u5185\u5b58\u5730\u5740<br \/>s\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">'alex'<\/span><br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(id(s))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#2278345368944<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u6587\u4ef6\u64cd\u4f5c\u76f8\u5173<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">open() : \u7528\u4e8e\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6, \u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u53e5\u67c4<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">f\u00a0=\u00a0open(<span style=\"color: #98c379; line-height: 26px;\">'file'<\/span>,mode=<span style=\"color: #98c379; line-height: 26px;\">'r'<\/span>,encoding=<span style=\"color: #98c379; line-height: 26px;\">'utf-8'<\/span>)<br \/>f.read()<br \/>f.close()<br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u6a21\u5757\u76f8\u5173<\/span><\/h2>\n<p style=\"margin-bottom: 20px; line-height: 1.8em; color: #3a3a3a;\">__ import__() : \u7528\u4e8e\u52a8\u6001\u52a0\u8f7d\u7c7b\u548c\u51fd\u6570<\/p>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u8ba9\u7528\u6237\u8f93\u5165\u4e00\u4e2a\u8981\u5bfc\u5165\u7684\u6a21\u5757<\/span><br \/>import\u00a0os<br \/>name\u00a0=\u00a0input(<span style=\"color: #98c379; line-height: 26px;\">\"\u8bf7\u8f93\u5165\u4f60\u8981\u5bfc\u5165\u7684\u6a21\u5757:\"<\/span>)<br \/>__import__(name)\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0\u53ef\u4ee5\u52a8\u6001\u5bfc\u5165\u6a21\u5757<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u5e2e \u00a0\u52a9<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">help() : \u51fd\u6570\u7528\u4e8e\u67e5\u770b\u51fd\u6570\u6216\u6a21\u5757\u7528\u9014\u7684\u8be6\u7ec6\u8bf4\u660e<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #e6c07b; line-height: 26px;\">help<\/span>(str))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u67e5\u770b\u5b57\u7b26\u4e32\u7684\u7528\u9014<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u8c03\u7528\u76f8\u5173<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">callable() : \u7528\u4e8e\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u53ef\u8c03\u7528\u7684. \u5982\u679c\u8fd4\u56deTrue, object\u6709\u53ef\u80fd\u8c03\u7528\u5931\u8d25, \u4f46\u5982\u679c\u8fd4\u56deFalse. \u90a3\u8c03\u7528\u7edd\u5bf9\u4e0d\u4f1a\u6210\u529f<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\">a\u00a0=\u00a010<br \/><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(callable(a))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#False\u00a0\u00a0\u53d8\u91cfa\u4e0d\u80fd\u88ab\u8c03\u7528<\/span><br \/><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#<\/span><br \/>def\u00a0f():<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(<span style=\"color: #98c379; line-height: 26px;\">\"hello\"<\/span>)<br \/>\u00a0\u00a0\u00a0\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(callable(f))\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0True\u00a0\u51fd\u6570\u662f\u53ef\u4ee5\u88ab\u8c03\u7528\u7684<\/span><br \/><\/code><\/pre>\n<h2 style=\"font-weight: bold; font-size: 22px; line-height: 1.5em; margin-top: 2.2em; margin-bottom: 35px;\"><span style=\"display: inline-block; background-image: linear-gradient(#ffffff 60%, #ffb11b 40%); background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: #515151; padding: 2px 13px; margin-right: 3px; height: 50%;\">\u67e5\u770b\u5185\u7f6e\u5c5e\u6027<\/span><\/h2>\n<ul class=\"list-paddingleft-2\" style=\"margin-top: 8px; margin-bottom: 8px; padding-left: 25px;\">\n<li>\n<section style=\"margin-top: 5px; margin-bottom: 5px; line-height: 26px; color: #010101;\">dir() : \u67e5\u770b\u5bf9\u8c61\u7684\u5185\u7f6e\u5c5e\u6027, \u8bbf\u95ee\u7684\u662f\u5bf9\u8c61\u4e2d\u7684__dir__()\u65b9\u6cd5<\/section>\n<\/li>\n<\/ul>\n<pre style=\"margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto; padding: 16px; color: #abb2bf; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; padding-top: 15px; background: #282c34; border-radius: 5px;\"><span style=\"color: #e6c07b; line-height: 26px;\">print<\/span>(dir(tuple))\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u67e5\u770b\u5143\u7ec4\u7684\u65b9\u6cd5<\/span><br \/><\/code><\/pre>\n<\/section>\n<section>\n<section>\n<section>\n<section>\n<section style=\"white-space: normal; font-size: 16px; background-color: #ffffff; text-align: center; word-spacing: 1px; caret-color: #333333; -webkit-user-drag: none; color: #3e3e3e; font-family: Arial; letter-spacing: 1px !important; line-height: 1.7 !important; margin: 20px !important 8px 20px !important 8px;\"><span style=\"font-size: 15px; font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, 'PingFang SC', Cambria, Cochin, Georgia, Times, 'Times New Roman', serif; font-weight: bold; letter-spacing: 0.544px; color: #737272;\">&#8211; \u5b8c &#8211;<\/span><\/section>\n<section style=\"margin-right: 8px; margin-left: 8px; padding-right: 0.5em; padding-left: 0.5em; font-family: -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal;\"><\/section>\n<section style=\"margin-right: 8px; margin-left: 8px; padding-right: 0.5em; padding-left: 0.5em; font-family: -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; white-space: normal;\"><\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/section>\n<\/div>\n\n\n<p>\u8f6c\u81ea\uff1ahttps:\/\/mp.weixin.qq.com\/s\/tnNpA3i_u-SQ2j8RAj1BEw<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1apypypypy\uff5c \u6765\u6e90\uff1a\u535a\u5ba2\u56ed \u00a0 \u5185\u7f6e\u51fd\u6570\u5c31\u662fPython\u7ed9\u4f60\u63d0\u4f9b\u7684, \u62ff\u6765\u76f4\u63a5\u7528\u7684\u51fd\u6570\uff0c\u6bd4\u5982pri &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=37993\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5efa\u8bae\u4f60\u5403\u900f Python \u7684 68 \u4e2a\u5185\u7f6e\u51fd\u6570\uff01\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/37993"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37993"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/37993\/revisions"}],"predecessor-version":[{"id":37998,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/37993\/revisions\/37998"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37993"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}