当前位置:首页 > 每日看点 > 正文内容

谁会写这道Python啊?求求了?

卡卷网1年前 (2024-12-14)每日看点243

面相结果编程:

print("+----+----+") print("| | |") print("| | |") print("| | |") print("| | |") print("+----+----+") print("| | |") print("| | |") print("| | |") print("| | |") print("+----+----+")


面相过程编程:

def prt_hline(): print("+----+----+") def prt_vline(): print("| | |") print("| | |") print("| | |") print("| | |") prt_hline() prt_vline() prt_hline() prt_vline() prt_hline()


面相对象编程:

class Grid: def __init__(self, rows=2, columns=2): self.rows = rows self.columns = columns def prt_hline(self): print("+" + "----+" * self.columns) def prt_vline(self): for _ in range(4): print("|" + " |" * self.columns) def display(self): for _ in range(self.rows): self.prt_hline() self.prt_vline() self.prt_hline() grid = Grid() grid.display()


面相函数式编程:

def prt_hline(columns): return "+" + "----+" * columns def prt_vline(columns): return "\n".join(["|" + " |" * columns for _ in range(4)]) def display(rows=2, columns=2, prt_hline_callback=prt_hline, prt_vline_callback=prt_vline): hlines = map(lambda _: prt_hline_callback(columns), range(rows + 1)) vlines = map(lambda _: prt_vline_callback(columns), range(rows)) grid_lines = [] for hline, vline in zip(hlines, vlines): grid_lines.append(hline) grid_lines.append(vline) grid_lines.append(prt_hline(columns)) print(*grid_lines, sep="\n") display()


面相封装API式编程:

# grid_module.py __version__ = "1.0.0" __author__ = "爱编程的Aten" class Grid: """A class to represent a grid of specified dimensions.""" def __init__(self, rows=2, columns=2): """Initialize the grid with the specified number of rows and columns.""" self.rows = rows self.columns = columns def _prt_hline(self): """Print a horizontal line of the grid.""" print("+" + "----+" * self.columns) def _prt_vline(self): """Print a vertical line of the grid.""" for _ in range(4): print("|" + " |" * self.columns) def display(self): """Display the entire grid.""" for _ in range(self.rows): self._prt_hline() self._prt_vline() self._prt_hline() def create_grid(rows=2, columns=2): """ Create and display a grid. Args: rows (int): Number of rows in the grid. columns (int): Number of columns in the grid. """ grid = Grid(rows, columns) grid.display() def main(): """Main function to run the grid display.""" create_grid() if __name__ == "__main__": main()


面相屎山式编程:

__import__("sys").exit( ( _ := ( lambda _builtins: [ _builtins.print( ( lambda _: "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[1]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[2]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[3]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[4]] + "+" )( [ ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << _[0]) + _[0] & _[3] )(1, 2, 3, 6), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ] ) ), [ _builtins.print( ( lambda _: "|" + " " + " " + " " + " " + "|" + " " + " " + " " + " " + "|" )([]) ) for _ in _builtins.range(4) ], _builtins.print( ( lambda _: "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[1]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[2]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[3]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[4]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + "+" )( [ ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << _[0]) + _[0] & _[3] )(1, 2, 3, 6), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ] ) ), [ _builtins.print( ( lambda _: "|" + " " + " " + " " + " " + "|" + " " + " " + " " + " " + "|" )([]) ) for _ in _builtins.range(4) ], _builtins.print( ( lambda _: "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + "+" + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[1]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[2]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[_[0]] + __builtins__.__getattribute__("object") .__call__() .__str__.__class__.__name__[-_[3]] + "+" )( [ ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << _[0]) + _[0] & _[3] )(1, 2, 3, 6), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ( lambda *_: (_[0] << ((_[0] << _[0]) + _[0] & _[1])) + (_[0] & _[2]) * (_[0] << ((_[0] << _[0]) + _[0] & _[2])) + (_[0] & _[3]) * (_[0] << _[0]) + _[0] & _[4] )(1, 3, 2, 4, 8), ] ) ), 0, ] ) )(__import__("builtins"))[-1] )



一更:

受到 @苏迟但到 的启发,再写一个

面相数据驱动逻辑编程:

[print("+|- - - - +|- - - - +|"[bool(i % 5)::2]) for i in range(11)]



二更:

再添加一个

面相自修改代码编程:

import marshal, base64, pickle, sys MAP = pickle.loads(b'\x80\x04\x95\x91\x03\x00\x00\x00\x00\x00\x00}\x94(\x8c\x07__prt_f\x94C\xd04wAAAAAAAAAAAAAAAAMAAAADAAAA8xoAAACXAHQBAAAAAAAAAABkAasBAAAAAAAAAQB5ACkCTnoLKy0tLS0rLS0tLSspAdoFcHJpbnSpAPMAAAAA+h48aXB5dGhvbi1pbnB1dC0yLTY1ZDgxMDQ4NWUzYz7aB19fcHJ0X2ZyBgAAAAEAAABzCgAAAIAA3AQJiC3VBBhyBAAAAA==\x94\x8c\x07__prt_y\x94BH\x01\x00\x004wAAAAAAAAAAAAAAAAMAAAADAAAA81wAAACXAHQBAAAAAAAAAABkAasBAAAAAAAAAQB0AQAAAAAAAAAAZAGrAQAAAAAAAAEAdAEAAAAAAAAAAGQBqwEAAAAAAAABAHQBAAAAAAAAAABkAasBAAAAAAAAAQB5ACkCTnoLfCAgICB8ICAgIHwpAdoFcHJpbnSpAPMAAAAA+h48aXB5dGhvbi1pbnB1dC0yLTY1ZDgxMDQ4NWUzYz7aB19fcHJ0X3lyBgAAAAUAAABzIgAAAIAA3AQJiC3UBBjcBAmILdQEGNwECYgt1AQY3AQJiC3VBBhyBAAAAA==\x94\x8c\x06__main\x94BH\x01\x00\x004wAAAAAAAAAAAAAAAAIAAAADAAAA82gAAACXAHQBAAAAAAAAAACrAAAAAAAAAAEAdAMAAAAAAAAAAKsAAAAAAAAAAQB0AQAAAAAAAAAAqwAAAAAAAAABAHQDAAAAAAAAAACrAAAAAAAAAAEAdAEAAAAAAAAAAKsAAAAAAAAAAQB5ACkBTikC2gdfX3BydF9m2gdfX3BydF95qQDzAAAAAPoePGlweXRob24taW5wdXQtOC1lOWE0MDVmYjY1ZDI+2gZfX21haW5yBwAAAAEAAABzGwAAAIAA3AQLhEncBAuESdwEC4RJ3AQLhEncBAuFSXIFAAAA\x94u.') def loads(func): if hash((*map(ord, sys.argv[1:]),)) != -4934787572747247300: return func org = func.__code__ def f(): nonlocal org func.__code__ = marshal.loads(base64.b64decode(MAP.get(func.__name__, b'4wAAAAAAAAAAAAAAAAAAAAADAAAA8wQAAACXAHkAKQFOqQByAgAAAPMAAAAA+gc8c3RkaW4++gg8bGFtYmRhPnIFAAAAAQAAAHMCAAAAgQByAwAAAA=='))) func() func.__code__ = org return f @loads def __prt_f(): print("fuck", end=" ") @loads def __prt_y(): print("you") @loads def __main(): __prt_f() __prt_y() __main()


运行时要用这个命令运行:

python 程序.py f c k



三更:

来个绝杀

面相GPT编程:

import os os.environ["OPENAI_API_KEY"] = "(填上你的OPENAI密钥)" from openai import OpenAI from requests import get from bs4 import BeautifulSoup res = get("https://www.zhihu.com/question/1386409733") res.raise_for_status() html = res.content.decode(res.apparent_encoding) text = BeautifulSoup(html).text completion = client.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "system", "content": "你是一个乐于助人的Python程序员。用户会给你提供一个知乎提问的网页,你要提供文字解答。"}, { "role": "user", "content": text } ] ) print(completion.choices[0].message)

扫描二维码推送至手机访问。

版权声明:本文由卡卷网发布,如需转载请注明出处。

本文链接:https://www.kajuan.net/ttnews/2024/12/4351.html

分享给朋友:

相关文章

有什么音乐软件可以全部免费下载歌曲?

有什么音乐软件可以全部免费下载歌曲?

作为音乐发烧友,我几乎把市面上所有的发烧碟、试音碟,全都给收藏,下载下来了!音质都是无损的,品质特别高,有5.1环绕的、有DTS的、有中文的、有英文的。大家可以看看这个音乐目录,大概有30万张专辑。有需要下载软件的朋友,可以双击屏幕,然后搓...

有没有推荐什么手游搬砖,或者是用手机就能做的工作能日入100左右就好了?

有没有推荐什么手游搬砖,或者是用手机就能做的工作能日入100左右就好了?

大家好,我是思聪。思聪游戏搬砖社每天分享真实靠谱的游戏赚钱的方法。整个游戏的攻略用一句话概括就是:打元宝兑换平台物品,xx元宝兑换一个分红物品。你把你打游戏得来的元宝去兑换平台的分红物品,就能每天领取xx元的分红。(具体看是哪个分红物品,比...

如何判断 Java 工程师的基础知识是否扎实?

我来给你出几道大题,能答对70%,你就算基础扎实了。第一部分 Java基础(27)1. 程序本质:代码是如何被执行的?CPU、操作系统、虚拟机各司何职?2. 基础语法:从CPU角度看变量、数组、类型、运算、跳转、函数等语法3. 引用类型:同...

为什么这次 Mac mini 的 M4 版本价格这么低?

为什么这次 Mac mini 的 M4 版本价格这么低?

扫了一眼这里的回答,目测没几个人真买过 Macbook、Mac mini且真正当主力工作机用过。这个初始(丐版)版本的机器实际谈不上多便宜,备受热捧有几个原因。它这代产品整体做了重新设计,大幅缩减了尺寸,真正称得上 Mini 了。对比前代,...

鸿蒙系统到底是不是安卓系统?

你好,是的。接下来我给不懂技术的人简单的说一下哄蒙系统的来龙去脉。首先你要知道什么是开源。‌‌开源(Open Source)全称为开放源代码‌,意味着任何人都可以获取和使用软件的源代码,并在遵守版权协议的前提下进行修改和再发布。‌12开源软...

你觉得oppo Find X8怎么样?

你觉得oppo Find X8怎么样?

OPPO FindX8发布也差不多一个月了,各位上手体验如何呢?作为OPPO的年度旗舰,性能,外观,屏幕等方面都有不小的提升,篇幅有限,下面挑最值得讲的两个点,就是OPPO Find X8的外观和影像。众所周知,这次OPPO Find X8...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。