首页 > 解决方案 > 如何在 google 上运行我的 python 代码并在不使用任何资金的情况下向公众或其他用户提供访问权限

问题描述

我已经使用 python 语言编写了一个程序,它可以告诉你的星座。我是在 Jupyter 笔记本 Anaconda 上完成的。我用word打开它,它的代码是:{

"cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Input birthday: 14\n",
      "Input month of birth: February\n",
      "Your Astrological sign is : Aquarius\n",
      "Element: Air\n",
      "Quality: Fixed\n",
      "Color: Light-Blue, Silver\n",
      "Day: Saturday\n",
      "Lucky Numbers: 4, 7, 11, 22, 29\n",
      "Lucky Metal: Iron\n",
      "Lucky Stone: Blue Sapphire\n",
      "Strengths: Progressive, original, independent, humanitarian\n",
      "Weaknesses: Runs from emotional expression, temperamental, uncompromising, aloof\n",
      "Aquarius likes: Fun with friends, helping others, fighting for causes, intellectual conversation, a good listener\n",
      "Aquarius dislikes: Limitations, broken promises, being lonely, dull or boring situations, people who disagree with them\n"
     ]
    }
   ],
   "source": [
    "day = int(input(\"Input birthday: \"))\n",
    "month = input(\"Input month of birth: \")\n",
    "astro_sign=''\n",
    "if month == 'december' or month == 'December':\n",
    "\tastro_sign = 'Sagittarius' if (day < 22) else 'Capricorn'\n",
    "elif month == 'january' or month == 'January':\n",
    "\tastro_sign = 'Capricorn' if (day < 20) else 'Aquarius'\n",
    "elif month == 'february' or month == 'February':\n",
    "\tastro_sign = 'Aquarius' if (day < 19) else 'Pisces'\n",
    "elif month == 'march' or month == 'March':\n",
    "\tastro_sign = 'Pisces' if (day < 21) else 'Aries'\n",
    "elif month == 'april' or month == 'April':\n",
    "\tastro_sign = 'Aries' if (day < 20) else 'Taurus'\n",
    "elif month == 'may' or month == 'May':\n",
    "\tastro_sign = 'Taurus' if (day < 21) else 'Gemini'\n",
    "elif month == 'june' or month == 'June':\n",
    "\tastro_sign = 'Gemini' if (day < 21) else 'Cancer'\n",
    "elif month == 'july' or month == 'July':\n",
    "\tastro_sign = 'Cancer' if (day < 23) else 'Leo'\n",
    "elif month == 'august' or month == 'August':\n",
    "\tastro_sign = 'Leo' if (day < 23) else 'Virgo'\n",
    "elif month == 'september' or month == 'September':\n",
    "\tastro_sign = 'Virgo' if (day < 23) else 'Libra'\n",
    "elif month == 'october' or month == 'October':\n",
    "\tastro_sign = 'Libra' if (day < 23) else 'Scorpio'\n",
    "elif month == 'november' or month == 'November':\n",
    "\tastro_sign = 'Scorpio' if (day < 22) else 'Sagittarius'\n",
    "else:\n",
    "  print('Invalid date entered!!!')\n",
    "print(\"Your Astrological sign is :\",astro_sign)\n",
    "if astro_sign == 'Sagittarius':\n",
    "  print('Element: Fire\\nQuality: Mutable\\nColor: Blue\\nDay: Thursday\\nLucky Numbers: 1, 3, 7, 9, 12, 21\\nLucky Metal: Bronze\\nLucky Stone: Yellow Sapphire.\\nStrengths: Generous, idealistic, great sense of humor\\nWeaknesses: Promises more than can deliver, very impatient, will say anything no matter how undiplomatic\\nSagittarius likes: Freedom, travel, philosophy, being outdoors\\nSagittarius dislikes: Clingy people, being constrained, off-the-wall theories, details')\n",
    "elif astro_sign == \"Capricorn\":\n",
    "  print(\"Element: Earth\\nQuality: Cardinal\\nColor: Brown, Black\\nDay: Saturday\\nLucky Numbers: 4, 8, 13, 22\\nLucky Metal: Iron\\nLucky Stone: Blue Sapphire\\nStrengths: Responsible, disciplined, self-control, good managers\\nWeaknesses: Know-it-all, unforgiving, condescending, expecting the worst\\nCapricorn likes: Family, tradition, music, understated status, quality craftsmanship\\nCapricorn dislikes: Almost everything at some point\")\n",
    "elif astro_sign == \"Aquarius\":\n",
    "  print(\"Element: Air\\nQuality: Fixed\\nColor: Light-Blue, Silver\\nDay: Saturday\\nLucky Numbers: 4, 7, 11, 22, 29\\nLucky Metal: Iron\\nLucky Stone: Blue Sapphire\\nStrengths: Progressive, original, independent, humanitarian\\nWeaknesses: Runs from emotional expression, temperamental, uncompromising, aloof\\nAquarius likes: Fun with friends, helping others, fighting for causes, intellectual conversation, a good listener\\nAquarius dislikes: Limitations, broken promises, being lonely, dull or boring situations, people who disagree with them\")\n",
    "elif astro_sign == \"Pisces\":\n",
    "  print(\"Element: Water\\nQuality: Mutable\\nColor: Mauve, Lilac, Purple, Violet, Sea green\\nDay: Thursday\\nLucky Numbers: 3, 9, 12, 15, 18, 24\\nLucky Metal: Bronze\\nLucky Stone: Yellow Sapphire\\nStrengths: Compassionate, artistic, intuitive, gentle, wise, musical\\nWeaknesses: Fearful, overly trusting, sad, desire to escape reality, can be a victim or a martyr\\nPisces likes: Being alone, sleeping, music, romance, visual media, swimming, spiritual themes\\nPisces dislikes: Know-it-all, being criticized, the past coming back to haunt, cruelty of any kind\")\n",
    "elif astro_sign == \"Aries\":\n",
    "  print(\"Element: Fire\\nQuality: Cardinal\\nColor: Red\\nDay: Tuesday\\nLucky Numbers: 1, 8, 17\\nLucky Metal\tCopper\\nLucky Stone\tRed Coral\\nStrengths: Courageous, determined, confident, enthusiastic, optimistic, honest, passionate\\nWeaknesses: Impatient, moody, short-tempered, impulsive, aggressive\\nAries likes: Comfortable clothes, taking on leadership roles, physical challenges, individual sports\\nAries dislikes: Inactivity, delays, work that does not use one's talents\")\n",
    "elif astro_sign == \"Taurus\":\n",
    "  print(\"Element: Earth\\nQuality: Fixed\\nColor: Green, Pink\\nDay: Friday, Monday\\nLucky Numbers: 2, 6, 9, 12, 24\\nLucky Metal: Silver\\nLucky Stone: Diamond\\nStrengths: Reliable, patient, practical, devoted, responsible, stable\\nWeaknesses: Stubborn, possessive, uncompromising\\nTaurus likes: Gardening, cooking, music, romance, high quality clothes, working with hands\\nTaurus dislikes: Sudden changes, complications, insecurity of any kind, synthetic fabrics\")\n",
    "elif astro_sign == \"Gemini\":\n",
    "  print(\"Element: Air\\nQuality: Mutable\\nColor: Light-Green, Yellow\\nDay: Wednesday\\nLucky Numbers: 5, 7, 14, 23\\nLucky Metal\tBronze\\nLucky Stone\tEmerald\\nStrengths: Gentle, affectionate, curious, adaptable, ability to learn quickly and exchange ideas\\nWeaknesses: Nervous, inconsistent, indecisive\\nGemini likes: Music, books, magazines, chats with nearly anyone, short trips around the town\\nGemini dislikes: Being alone, being confined, repetition and routine\")\n",
    "elif astro_sign == \"Cancer\":\n",
    "  print(\"Element: Water\\nQuality: Cardinal\\nColor: White\\nDay: Monday, Thursday\\nLucky Numbers: 2, 3, 15, 20\\nLucky Metal: Silver\\nLucky Stone: Pearl\\nStrengths: Tenacious, highly imaginative, loyal, emotional, sympathetic, persuasive\\nWeaknesses: Moody, pessimistic, suspicious, manipulative, insecure\\nCancer likes: Art, home-based hobbies, relaxing near or in water, helping loved ones, a good meal with friends\\nCancer dislikes: Strangers, any criticism of Mom, revealing of personal life\")\n",
    "elif astro_sign == \"Leo\":\n",
    "  print(\"Element: Fire\\nQuality: Fixed\\nColor: Gold, Yellow, Orange\\nDay: Sunday\\nLucky Numbers: 1, 3, 10, 19\\nLucky Metal: Copper\\nLucky Stone\tRuby\\nStrengths: Creative, passionate, generous, warm-hearted, cheerful, humorous\\nWeaknesses: Arrogant, stubborn, self-centered, lazy, inflexible\\nLeo likes: Theater, taking holidays, being admired, expensive things, bright colors, fun with friends\\nLeo dislikes: Being ignored, facing difficult reality, not being treated like a king or queen\")\n",
    "elif astro_sign == \"Virgo\":\n",
    "  print(\"Element: Earth\\nQuality: Mutable\\nColor: Grey, Beige, Pale-Yellow\\nDay: Wednesday\\nLucky Numbers: 5, 14, 15, 23, 32\\nLucky Metal: Bronze\\nLucky Stone Emerald\\nStrengths: Loyal, analytical, kind, hardworking, practical\\nWeaknesses: Shyness, worry, overly critical of self and others, all work and no play\\nVirgo likes: Animals, healthy food, books, nature, cleanliness\\nVirgo dislikes: Rudeness, asking for help, taking center stage\")\n",
    "elif astro_sign == \"Libra\":\n",
    "  print(\"Element: Air\\nQuality: Cardinal\\nColor: Pink, Green\\nDay: Friday\\nLucky Numbers: 4, 6, 13, 15, 24\\nLucky Metal\tSilver\\nLucky Stone\tDiamond\\nStrengths: Cooperative,diplomatic, gracious, fair-minded, social\\nWeaknesses: Indecisive, avoids confrontations, will carry a grudge, self-pity\\nLibra likes: Harmony, gentleness, sharing with others, the outdoors\\nLibra dislikes: Violence, injustice, loudmouths, conformity\")\n",
    "elif astro_sign == \"Scorpio\":\n",
    "  print(\"Element: Water\\nQuality: Fixed\\nColor: Scarlet, Red, Rust\\nDay: Tuesday\\nLucky Numbers: 8, 11, 18, 22\\nLucky Metal\tCopper\\nLucky Stone\tRed Coral\\nStrengths: Resourceful, brave, passionate, stubborn, a true friend\\nWeaknesses: Distrusting, jealous, secretive, violent\\nScorpio likes: Truth, facts, being right, longtime friends, teasing, a grand passion\\nScorpio dislikes: Dishonesty, revealing secrets, passive people\")\n",
    "else:\n",
    "  print(\"You've entered the wrong date so no sign traits for youuuu!!!!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

在 Jupiter notebook 上,代码为:

day = int(input("Input birthday: "))
month = input("Input month of birth: ")
astro_sign=''
if month == 'december' or month == 'December':
    astro_sign = 'Sagittarius' if (day < 22) else 'Capricorn'
elif month == 'january' or month == 'January':
    astro_sign = 'Capricorn' if (day < 20) else 'Aquarius'
elif month == 'february' or month == 'February':
    astro_sign = 'Aquarius' if (day < 19) else 'Pisces'
elif month == 'march' or month == 'March':
    astro_sign = 'Pisces' if (day < 21) else 'Aries'
elif month == 'april' or month == 'April':
    astro_sign = 'Aries' if (day < 20) else 'Taurus'
elif month == 'may' or month == 'May':
    astro_sign = 'Taurus' if (day < 21) else 'Gemini'
elif month == 'june' or month == 'June':
    astro_sign = 'Gemini' if (day < 21) else 'Cancer'
elif month == 'july' or month == 'July':
    astro_sign = 'Cancer' if (day < 23) else 'Leo'
elif month == 'august' or month == 'August':
    astro_sign = 'Leo' if (day < 23) else 'Virgo'
elif month == 'september' or month == 'September':
    astro_sign = 'Virgo' if (day < 23) else 'Libra'
elif month == 'october' or month == 'October':
    astro_sign = 'Libra' if (day < 23) else 'Scorpio'
elif month == 'november' or month == 'November':
    astro_sign = 'Scorpio' if (day < 22) else 'Sagittarius'
else:
  print('Invalid date entered!!!')
print("Your Astrological sign is :",astro_sign)
if astro_sign == 'Sagittarius':
  print('Element: Fire\nQuality: Mutable\nColor: Blue\nDay: Thursday\nLucky Numbers: 1, 3, 7, 9, 12, 21\nLucky Metal: Bronze\nLucky Stone: Yellow Sapphire.\nStrengths: Generous, idealistic, great sense of humor\nWeaknesses: Promises more than can deliver, very impatient, will say anything no matter how undiplomatic\nSagittarius likes: Freedom, travel, philosophy, being outdoors\nSagittarius dislikes: Clingy people, being constrained, off-the-wall theories, details')
elif astro_sign == "Capricorn":
  print("Element: Earth\nQuality: Cardinal\nColor: Brown, Black\nDay: Saturday\nLucky Numbers: 4, 8, 13, 22\nLucky Metal: Iron\nLucky Stone: Blue Sapphire\nStrengths: Responsible, disciplined, self-control, good managers\nWeaknesses: Know-it-all, unforgiving, condescending, expecting the worst\nCapricorn likes: Family, tradition, music, understated status, quality craftsmanship\nCapricorn dislikes: Almost everything at some point")
elif astro_sign == "Aquarius":
  print("Element: Air\nQuality: Fixed\nColor: Light-Blue, Silver\nDay: Saturday\nLucky Numbers: 4, 7, 11, 22, 29\nLucky Metal: Iron\nLucky Stone: Blue Sapphire\nStrengths: Progressive, original, independent, humanitarian\nWeaknesses: Runs from emotional expression, temperamental, uncompromising, aloof\nAquarius likes: Fun with friends, helping others, fighting for causes, intellectual conversation, a good listener\nAquarius dislikes: Limitations, broken promises, being lonely, dull or boring situations, people who disagree with them")
elif astro_sign == "Pisces":
  print("Element: Water\nQuality: Mutable\nColor: Mauve, Lilac, Purple, Violet, Sea green\nDay: Thursday\nLucky Numbers: 3, 9, 12, 15, 18, 24\nLucky Metal: Bronze\nLucky Stone: Yellow Sapphire\nStrengths: Compassionate, artistic, intuitive, gentle, wise, musical\nWeaknesses: Fearful, overly trusting, sad, desire to escape reality, can be a victim or a martyr\nPisces likes: Being alone, sleeping, music, romance, visual media, swimming, spiritual themes\nPisces dislikes: Know-it-all, being criticized, the past coming back to haunt, cruelty of any kind")
elif astro_sign == "Aries":
  print("Element: Fire\nQuality: Cardinal\nColor: Red\nDay: Tuesday\nLucky Numbers: 1, 8, 17\nLucky Metal   Copper\nLucky Stone Red Coral\nStrengths: Courageous, determined, confident, enthusiastic, optimistic, honest, passionate\nWeaknesses: Impatient, moody, short-tempered, impulsive, aggressive\nAries likes: Comfortable clothes, taking on leadership roles, physical challenges, individual sports\nAries dislikes: Inactivity, delays, work that does not use one's talents")
elif astro_sign == "Taurus":
  print("Element: Earth\nQuality: Fixed\nColor: Green, Pink\nDay: Friday, Monday\nLucky Numbers: 2, 6, 9, 12, 24\nLucky Metal: Silver\nLucky Stone: Diamond\nStrengths: Reliable, patient, practical, devoted, responsible, stable\nWeaknesses: Stubborn, possessive, uncompromising\nTaurus likes: Gardening, cooking, music, romance, high quality clothes, working with hands\nTaurus dislikes: Sudden changes, complications, insecurity of any kind, synthetic fabrics")
elif astro_sign == "Gemini":
  print("Element: Air\nQuality: Mutable\nColor: Light-Green, Yellow\nDay: Wednesday\nLucky Numbers: 5, 7, 14, 23\nLucky Metal   Bronze\nLucky Stone Emerald\nStrengths: Gentle, affectionate, curious, adaptable, ability to learn quickly and exchange ideas\nWeaknesses: Nervous, inconsistent, indecisive\nGemini likes: Music, books, magazines, chats with nearly anyone, short trips around the town\nGemini dislikes: Being alone, being confined, repetition and routine")
elif astro_sign == "Cancer":
  print("Element: Water\nQuality: Cardinal\nColor: White\nDay: Monday, Thursday\nLucky Numbers: 2, 3, 15, 20\nLucky Metal: Silver\nLucky Stone: Pearl\nStrengths: Tenacious, highly imaginative, loyal, emotional, sympathetic, persuasive\nWeaknesses: Moody, pessimistic, suspicious, manipulative, insecure\nCancer likes: Art, home-based hobbies, relaxing near or in water, helping loved ones, a good meal with friends\nCancer dislikes: Strangers, any criticism of Mom, revealing of personal life")
elif astro_sign == "Leo":
  print("Element: Fire\nQuality: Fixed\nColor: Gold, Yellow, Orange\nDay: Sunday\nLucky Numbers: 1, 3, 10, 19\nLucky Metal: Copper\nLucky Stone Ruby\nStrengths: Creative, passionate, generous, warm-hearted, cheerful, humorous\nWeaknesses: Arrogant, stubborn, self-centered, lazy, inflexible\nLeo likes: Theater, taking holidays, being admired, expensive things, bright colors, fun with friends\nLeo dislikes: Being ignored, facing difficult reality, not being treated like a king or queen")
elif astro_sign == "Virgo":
  print("Element: Earth\nQuality: Mutable\nColor: Grey, Beige, Pale-Yellow\nDay: Wednesday\nLucky Numbers: 5, 14, 15, 23, 32\nLucky Metal: Bronze\nLucky Stone Emerald\nStrengths: Loyal, analytical, kind, hardworking, practical\nWeaknesses: Shyness, worry, overly critical of self and others, all work and no play\nVirgo likes: Animals, healthy food, books, nature, cleanliness\nVirgo dislikes: Rudeness, asking for help, taking center stage")
elif astro_sign == "Libra":
  print("Element: Air\nQuality: Cardinal\nColor: Pink, Green\nDay: Friday\nLucky Numbers: 4, 6, 13, 15, 24\nLucky Metal Silver\nLucky Stone Diamond\nStrengths: Cooperative,diplomatic, gracious, fair-minded, social\nWeaknesses: Indecisive, avoids confrontations, will carry a grudge, self-pity\nLibra likes: Harmony, gentleness, sharing with others, the outdoors\nLibra dislikes: Violence, injustice, loudmouths, conformity")
elif astro_sign == "Scorpio":
  print("Element: Water\nQuality: Fixed\nColor: Scarlet, Red, Rust\nDay: Tuesday\nLucky Numbers: 8, 11, 18, 22\nLucky Metal Copper\nLucky Stone Red Coral\nStrengths: Resourceful, brave, passionate, stubborn, a true friend\nWeaknesses: Distrusting, jealous, secretive, violent\nScorpio likes: Truth, facts, being right, longtime friends, teasing, a grand passion\nScorpio dislikes: Dishonesty, revealing secrets, passive people")
else:
  print("You've entered the wrong date so no sign traits for youuuu!!!!")

那么如何让这段代码在公开显示的谷歌上运行,并且可以在不使用任何金钱的情况下将链接分享给朋友和家人

标签: pythonpython-3.xhosting

解决方案


Colab 与 jupyter notebook 非常相似,可以免费使用。添加代码后,只需将链接发送给其他人。https://colab.research.google.com/是链接​​。快速指南是:https ://colab.research.google.com/github/jckantor/CBE30338/blob/master/docs/01.01-Getting-Started-with-Python-and-Jupyter-Notebooks.ipynb


推荐阅读