- Python AI游戲編程入門:基于Pygame和PyTorch
- 肖凱
- 90字
- 2024-10-25 14:10:50
2.4.1 random模塊
如名稱的含義所示,random模塊用于生成偽隨機數。下面的例子中,使用random模塊的randint函數,可以生成1~10的任意一個整數數字。隨機數的引入可以增強游戲的隨機性,讓游戲更為有趣。
import random
x = random.randint(1,10)
print(x)
推薦閱讀
- Instant Node Package Manager
- Microsoft Dynamics 365 Extensions Cookbook
- C# 從入門到項目實踐(超值版)
- VSTO開發入門教程
- Learn Swift by Building Applications
- C++程序設計基礎教程
- uni-app跨平臺開發與應用從入門到實踐
- Arduino Wearable Projects
- Python應用與實戰
- Flink核心技術:源碼剖析與特性開發
- SaaS攻略:入門、實戰與進階
- Kohana 3.0 Beginner's Guide
- 從零開始學UI設計·基礎篇
- C++ Data Structures and Algorithm Design Principles
- Build Your Own PaaS with Docker