你可以使用ChatGPT进行调试、代码生成、重构、注释等操作。它可以处理40多种编程语言的代码。

上古语言 早期语言 近期语言 先锋语言
BASIC Perl Swift Kotlin
Assembly Pascal TypeScript Julia
Fortran PHP Rust Crystal
Lisp Prolog Kotlin/Native Racket
COBOL C Julia (GPU) Lua
Algol PL/I Go Zig
SNOBOL C++ Dart Nim
RPG Smalltalk Elixir Crystal (LLVM)
Forth Tcl Groovy Vlang
Ada SQL Scala Native Erlang

代码生成

指导ChatGPT生成代码,就像呼吸一样简单::

  1. Act as a junior python programmer. Please write the code to generate madlibs from 3 arrays of 6 items each: prepositions, verbs and nouns, with the nouns also being used as direct objects. After writing it, execute the code.

输出结果可能像下面一样:

  1. import random
  2. prepositions = ['at', 'in', 'on', 'with', 'under', 'over']
  3. verbs = ['run', 'jump', 'dance', 'sing', 'laugh', 'cry']
  4. nouns = ['cat', 'dog', 'tree', 'flower', 'book', 'computer']
  5. preposition = random.choice(prepositions)
  6. verb = random.choice(verbs)
  7. noun = random.choice(nouns)
  8. madlib = f"I {verb} {preposition} the {noun}."
  9. print(madlib)

试试这个Dyno插件的功能:

提示词:

扮演一名初级 Python 程序员。请编写代码,从 3 个数组(每个数组包含 6 个项目)生成 madlib:介词、动词和名词,名词也用作直接宾语。

AI 回复:

  1. # Create arrays of prepositions, verbs, and nouns
  2. prepositions = ["in", "on", "under", "above", "beside", "through"]
  3. verbs = ["ran", "jumped", "skipped", "crawled", "danced", "climbed"]
  4. nouns = ["tree", "rock", "bush", "flower", "house", "hill"]
  5. # Create a for loop to iterate through the arrays
  6. for i in range(len(prepositions)):
  7. # Print the madlibs
  8. print("The rabbit "+verbs[i]+" "+prepositions[i]+" the "+nouns[i]+".")