1. Python can pass two kinds of parameters and return multiple values
Usually, a parameter and return value can only be of one type. In C/C + +, Java and golang, it is impossible to return two types, or pass parameters to use two types, but it is possible in Python.
def mytest(a:str or int)->str or int:
return a*2
2. Using Uinon in Python
from typing import Union
def mytest(a:Union[str,int])->Union[str,int]:
return a*2
Read More:
- SQL Union, union all usage and common errors and Solutions
- Essay (19) Ubuntu 16 + python2.7 update PIP report error no module named typing
- In Python sys.argv Usage of
- Yield usage in Python
- Importerror: no module named typing error reporting solution (python2 PIP needs to be backed back from 21)
- Usage of Python dropout
- AttAttributeError: module ‘typing‘ has no attribute ‘NoReturn‘
- VNC logon when Connection union (10061) resolves
- Usage and examples of three important functions of tidyr package in R language: gather, spread and separate
- Raise in Oracle_APPLICATION_Error Usage
- C++:error C2228: left of ‘.str’ must have class/struct/union
- The function and usage of argc and argv in C language
- Usage of NVL in SQL
- On fileZilla unable to connect FATAL ERROR: Connection union
- Usage of pause function in MATLAB
- The usage and difference of atoi() and stoi() functions in C + +
- JS exception capture: the usage and example analysis of onerror() in window
- svn Key usage violation in certificate has been detected
- The usage of several integer functions in MATLAB (fix, floor, ceil, round)
- On the usage of ‘ref.stor.type search’ field in SAP WM movement type